package graph;

import java.io.*;
import java.util.*;
import zclTool.*;

public class Map0204uniqToIds {

	/**
	 * @param args
	 */

	public static void loadAttributeId(String file) {
		try {
			DelimitedReader dr = new DelimitedReader(file);
			String[] line;
			while ((line = dr.read()) != null) {
				int id = Integer.parseInt(line[0].trim());
				String ib = line[1].trim();
				String att = line[2].trim();
				name2id.put(ib + "@" + att, id);
			}
			dr.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	static HashMap<String, Integer> name2id = new HashMap<String, Integer>();

	public static void main(String[] args) throws Exception {

		// TODO Auto-generated method stub
		loadAttributeId("attributes");

		DelimitedReader dr = new DelimitedReader("0204unqies");
		OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
				"0204uniqes_id"));
		String[] line;
		int ln = 0; 
		while ((line = dr.read()) != null) {
			System.out.println(ln);
			ln++;
			int num = Integer.parseInt(line[1]);
			osw.write(num+"\t");
			String[] atts = line[2].split(", ");
			for (String att : atts) {
				att = att.trim();
				Integer idint = name2id.get(att);
				if (idint != null) {
					int id = idint;
					// System.out.print(id+"\t");
					osw.write(id + ",");
				} else {
					System.out.println(att);
				}

			}
			osw.write("\n");
		}
		dr.close();
		osw.close();

	}

}
